package net.sxnic.ugr.user.taglib;

import java.io.IOException;
import java.util.Set;

import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyTagSupport;

import org.apache.commons.lang.StringUtils;

import net.sxnic.ugr.user.User;

public class UserIteratorNameTag extends BodyTagSupport{

	private static final long serialVersionUID = 8362916037651739420L;

	private Set<User> users;
	
	public int doEndTag() {
		JspWriter out = pageContext.getOut();
		
		try {
			if(users == null || users.size()<=0){
				out.print("");
			}else{
				String temp = "";
				for(User u:users){
					temp = temp + u.getFullname()+",";
				}
				out.print(StringUtils.removeEnd(temp, ","));
			}
			
		} catch (IOException e) {
			
		}

		return EVAL_PAGE;
	}

	public Set<User> getUsers() {
		return users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}

}
